package com.yinhe.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yinhe.common.annotation.Log;
import com.yinhe.common.core.controller.BaseController;
import com.yinhe.common.core.domain.AjaxResult;
import com.yinhe.common.enums.BusinessType;
import com.yinhe.system.domain.YhContentActivitys;
import com.yinhe.system.service.IYhContentActivitysService;
import com.yinhe.common.utils.poi.ExcelUtil;
import com.yinhe.common.core.page.TableDataInfo;

/**
 * 活动内容Controller
 * 
 * @author yinhe
 * @date 2022-09-01
 */
@RestController
@RequestMapping("/system/activitys")
public class YhContentActivitysController extends BaseController
{
    @Autowired
    private IYhContentActivitysService yhContentActivitysService;

    /**
     * 查询活动内容列表
     */
    @PreAuthorize("@ss.hasPermi('system:activitys:list')")
    @GetMapping("/list")
    public TableDataInfo list(YhContentActivitys yhContentActivitys)
    {
        startPage();
        List<YhContentActivitys> list = yhContentActivitysService.selectYhContentActivitysList(yhContentActivitys);
        return getDataTable(list);
    }

    /**
     * 导出活动内容列表
     */
    @PreAuthorize("@ss.hasPermi('system:activitys:export')")
    @Log(title = "活动内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YhContentActivitys yhContentActivitys)
    {
        List<YhContentActivitys> list = yhContentActivitysService.selectYhContentActivitysList(yhContentActivitys);
        ExcelUtil<YhContentActivitys> util = new ExcelUtil<YhContentActivitys>(YhContentActivitys.class);
        util.exportExcel(response, list, "活动内容数据");
    }

    /**
     * 获取活动内容详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:activitys:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(yhContentActivitysService.selectYhContentActivitysById(id));
    }

    /**
     * 新增活动内容
     */
    @PreAuthorize("@ss.hasPermi('system:activitys:add')")
    @Log(title = "活动内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YhContentActivitys yhContentActivitys)
    {
        return toAjax(yhContentActivitysService.insertYhContentActivitys(yhContentActivitys));
    }

    /**
     * 修改活动内容
     */
    @PreAuthorize("@ss.hasPermi('system:activitys:edit')")
    @Log(title = "活动内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YhContentActivitys yhContentActivitys)
    {
        return toAjax(yhContentActivitysService.updateYhContentActivitys(yhContentActivitys));
    }

    /**
     * 删除活动内容
     */
    @PreAuthorize("@ss.hasPermi('system:activitys:remove')")
    @Log(title = "活动内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yhContentActivitysService.deleteYhContentActivitysByIds(ids));
    }
}
